#ifndef __MALLOC2_H__
#define __MALLOC2_H__
#include <stdio.h>



void* malloc2(size_t size);
void  free2(void *p);

/*
// visible of ‘linked list’
list 1
NULL <- prev 
        next -> NULL 
        1 

list 2
NULL <- prev <- prev
         1        2
        next ->  next -> NULL 

list 3
NULL <- prev <- prev <- prev
         1        2      3
        next -> next -> next -> NULL 

// append
    curr->prev = last;
    curr->next = NULl;
    last->next = curr;

// insert (pos, cur) 
    cur->prev = pos;
    cur->next = pos->next;
    pos->next->prev = cur;
    pos->next = cur;

    => operation logic 
        => Z -> /
            => Z : update cur prev and next first
            => / : pos->next->prev, then pos->next

// remove (pos)
    pos->prev->next = pos->next;
    pos->next->prev = pos->prev;

*/

/*
// think about 
// whether need loop merge or not

free case (f: free, u:used)
NULL <- 1u <-> 2u <-> 3u -> NULL

free 2 
NULL <- 1u <-> 2f <-> 3u -> NULL

free 1 # merge next trigger
NULL <- 1f        <-> 3u -> NULL // <- 1f <-> 2f <-> 3u ->

free 3 # merge prev trigger
NULL <- 1f               -> NULL // <- 1f        <-> 3f ->

// conclution: not necessary
*/



#endif